package geovis.springcloud.demo.task;

import org.springframework.cloud.task.listener.TaskExecutionListener;
import org.springframework.cloud.task.repository.TaskExecution;
import org.springframework.stereotype.Component;

import java.util.logging.Logger;

@Component
public class MyTaskListener implements TaskExecutionListener {
    private static final Logger log = Logger.getLogger("MyTaskListener");

    @Override
    public void onTaskStartup(TaskExecution taskExecution) {
        log.info("starting task:" + taskExecution.getTaskName());
    }

    @Override
    public void onTaskEnd(TaskExecution taskExecution) {
        log.info("ending task:" + taskExecution.getTaskName());
    }

    @Override
    public void onTaskFailed(TaskExecution taskExecution, Throwable throwable) {
        log.info("task failed:" + taskExecution.getTaskName());
        log.info("error msg:"+throwable.getMessage());
    }
}
